package cn.bonoon.kernel.web.handlers.loader;

import java.lang.reflect.Field;

import cn.bonoon.handler.impl.StandardAutoManager;
import cn.bonoon.kernel.support.searcher.Finder;
import cn.bonoon.kernel.web.annotations.AutoDataLoader;
import cn.bonoon.kernel.web.annotations.AutoDataResultFields;

public abstract class BaseComboAutoLoaderHandler extends ComboAutoLoaderHandler {

	protected String selectFields;
	
	protected BaseComboAutoLoaderHandler(StandardAutoManager manager, Class<?> queryClass, AutoDataLoader loader, Field field) throws Exception {
		super(manager, queryClass, loader, field);
		
		__init(field);
	}

	protected BaseComboAutoLoaderHandler(StandardAutoManager manager, AutoDataLoader loader, Field field) throws Exception {
		super(manager, loader, field);
		
		__init(field);
	}

	private void __init(Field field){
		AutoDataResultFields resultFields = field.getAnnotation(AutoDataResultFields.class);
		if(null != resultFields){
			selectFields = resultFields.value();
		}else{
			selectFields = Finder.DEFAULT_SELECT_FIELDS;
		}
	}
}
